package com.csd.service.impl;

import com.csd.dao.AdminDao;
import com.csd.dao.UserDao;
import com.csd.pojo.Admin;
import com.csd.pojo.SysUser;
import com.csd.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ Author :lihainan
 * @ ClassNmae :AdminServiceImpl
 * @ Description :TODO
 * @ Date :2020/12/23
 * @ Version 1.0
 */
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private UserDao userDao;
    @Autowired
    private AdminDao adminDao;

    @Override
    public List<SysUser> findAllSysUser() {
        List<SysUser> allSysUser = userDao.findAllSysUser();

        return allSysUser;
    }

    @Override
    public Admin findAdmin(Admin admin) {
        String adminname = admin.getAdminname();
        String password = admin.getPassword();
        Admin adminByName = adminDao.findAdminByNameAndPassword(adminname, password);

        return adminByName;
    }

    @Override
    public SysUser findAllSysUserById(int id) {

        SysUser sysUser = userDao.finduserById(id);
        return sysUser;
    }

    @Override
    public int delSysUserById(int id) {
        int code = userDao.delUserById(id);
        return code ;
    }

    @Override
    public int modifySysUserById(SysUser sysUser) {
      int code = userDao.updateSysUser(sysUser);

        return code;
    }
}
